﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace LIMS.Web
{
    public partial class AdminTeacherAdd : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            mesEmptyError.InnerText = "";
        }

        protected void btnOK_Click(object sender, EventArgs e)
        {

            Model.Teachers teacher = new Model.Teachers()
            {
                teacherID = txtTeacherID.Text.Trim(),
                teacherName = txtTeacherName.Text.Trim(),
                teacherPwd = txtPwd1.Text.Trim()
            };
            if (BLL.TeacherManager.GetTeacherByID(teacher.teacherID) == null)
            {
                BLL.TeacherManager.AddTeacher(teacher);
                Response.Redirect("AdmTeacManange.aspx");
            }
        }

        protected void btnCheckTeacher_Click(object sender, EventArgs e)
        {
            if (BLL.TeacherManager.GetTeacherByID(txtTeacherID.Text.Trim()) != null)
            {
                mesEmptyError.InnerText = "该教师ID已经被使用！";
                return;
            }
            else
            {
                mesEmptyError.InnerText = "可以注册！";
                return;
            }
        }
    }
}